package com.bookstore.entity.pojo;

import com.bookstore.constant.ResConstant;
import lombok.Getter;

@Getter
public class R <T> {
    private int code;
    private String msg;
    private T data;



    private R ()  {
    }

    public static <T> R<T> success (T date) {
        R<T> r = new R<>();

        r.code = ResConstant.SUCCESS;
        r.msg = "成功";
        r.data = date;
        return r;
    }

    public static <T> R<T> success () {
        R<T> r = new R<>();

        r.code = ResConstant.SUCCESS;
        r.msg = "成功";
        return r;
    }
    public static <T> R<T> error (T date) {
        R<T> r = new R<>();

        r.code = ResConstant.ERROR;
        r.msg = "失败";
        r.data = date;
        return r;
    }

    public static <T> R<T> error () {
        R<T> r = new R<>();

        r.code = ResConstant.ERROR;
        r.msg = "失败";
        return r;
    }

}
